Ccay.Module.define("Ccay.example.ui.igird.filter",function(page,$S){
	 
	page.ready = function(){
		var gridOption = {
			height: 280,
			allowFilter :true,
			editMode: true,
			showStatus : true,
			storageOp:{
				cache: true, // 是否缓存数据
				cacheKey: ["id"] // 缓存key
			},
		    columns: [
		  		 {field: 'id', columnType:'select', multi:true},
				 {field:"name",name:"string name",width:100,filter:true,rule : {required : true,specialch:true,maxlength : 20}},
				 {field: 'sex',name: "bool Sex",width:100,type:"bool",filter:{defines:[{value : 1, text:"男"},{value : 0,text :"女"}]}},
				 {field:"age",name:"integer age",type:"integer",width:100, filter :{defines :[{operation:"lessThan", value : 60},{operation:"equalsGreatThan", value : 60} ]}},
				 {field: 'province', width:70, name: "enum province", type: 'enum',filter:{enumable : true,multi:true}, editorOp: {id: "comboProvince"}, format: {service:"LOOKUP2:province",valueField:"itemCode",displayField:"itemName"},width:100},
				 {field:"birthday",name:"User Birthday",type:"date",width:150, filter :true},
				 {field:"lastUpdateDate",name:"lastUpdateDate",type:"datetime",width:150, filter :true, content: "${#getLastTime(lastUpdateDate)}"}
		    ],
			ajax:{
		  	 	url:'services/ccay/demo/student/list/page/filter/${pageSize}/${curPage}/${filter}'
			},
		    operation: {
		    	del: {
		    		btn: '#btnDel1',
		    		undoBtn: '#btnUndoDel1'
		    	},
		    	insert: {
		    		btn: '#btnAdd1',
		    		copy: true,
		    		clear: ['id', 'name', 'lastUpdateDate'],
		    		defaultRow:{sex:1, blog:'http://', tuition:'0'}
		    	},
		    	save: {
		    		btn: '#btnSave1',
		    		ajax: {
		    			url: "services/ccay/demo/student/batch"
		    		}
		    	}
		    }
		};
		
		$S("#filterFunctionDemo").ccayTab();
		
		//点击tab头后，才加载数据，只第一次生效
		$S("li[tabid='tab2']").one("click", function () {
			$S("#iGrid1").igrid(gridOption);
		});
	
		var suggestOps = {
				url: "services/ccay/demo/student/list/page/${suggestNum}/1",
				valueField: "address",
				displayField: "address",
				fieldMapper: {
					name: "sName",
					address: "sAddress",
					sex: "sSex"
				}
			};
		
		var popupOps = {
				igrid: true,
				servicePath: "services/ccay/demo/student/list",
				uniqueKey: "id",
				displayField: "name",
				columns: [
					{header: "sName", field: 'name'},
					{header: "sSex", field: 'sex'},
					{header: "sAddress", field: 'address'}
				]
			};
		
		
	var gridOption2 = {
		height: 280,
		wrap: true,
		allowFilter :true,
		showSwitch:true,
		switchMode:"search",
		editMode: true,
		showStatus : true,
		wrapHead : false,
		genSearchByFilter:true,
	    columns: [
		         {field: 'id', columnType:'select', multi:true},
				 {field:"name",header:"string name",width:100,filter:true,rule : {required : true,specialch:true,maxlength : 20}},
				 {field: 'address', valueField: "address", width:100, header: "address",type:"suggest", filter :true , renderer: 'enum', editorOp: {type: "suggest", conf: suggestOps}},
				 {field: 'sex',header: "bool Sex",width:100,type:"bool",filter:{defines:[{value : 1, text:"男"},{value : 0,text :"女"}]}},
				 {field:"age",header:"integer age",type:"integer",width:100, filter :{defines :[{operation:"lessThan", value : 60},{operation:"equalsGreatThan", value : 60} ]}},
				 {field: 'province', width:70, header: "enum province", type: 'enum',filter:true, editorOp: {id: "comboProvince"}, format: {service:"LOOKUP2:province",valueField:"itemCode",displayField:"itemName"},width:100},
				 {field:"birthday",header:"User Birthday",type:"date",width:150, filter :true},
				 {field:"lastUpdateDate",header:"lastUpdateDate",type:"datetime",width:150,filter :{range:true}, content: "${#getLastTime(lastUpdateDate)}"}
	    ],
		ajax:{
	  	 	url:'services/ccay/demo/student/list/page/filter/${pageSize}/${curPage}/${filter}'
		},
	    operation: {
	    	del: {
	    		btn: '#btnDel2',
	    		undoBtn: '#btnUndoDel2'
	    	},
	    	insert: {
	    		btn: '#btnAdd2',
	    		copy: true,
	    		clear: ['id', 'name', 'lastUpdateDate'],
	    		defaultRow:{sex:1, blog:'http://', tuition:'0'}
	    	},
	    	save: {
	    		btn: '#btnSave2',
	    		ajax: {
	    			url: "services/ccay/demo/student/batch"
	    		}
	    	},
			search:{
				panel:'#searchForm'
			}
	    }
	};	
	
	getLastTime = function(data){
		return Ccay.Format.toDateBefore(data && data.getUTCTime());
	};
	
	//点击tab头后，才加载数据，只第一次生效
	$S("li[tabid='tab3']").one("click", function () {
		$S("#iGrid2").igrid(gridOption2);
	});
};
	
});